package com.github.pig.nideshop.controller.user;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.github.pig.common.util.ZyResult;
import com.github.pig.nideshop.entity.NideshopSubscribe;
import com.github.pig.nideshop.service.INideshopSubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  预约前端控制器
 * </p>
 *
 * @author J神
 * @since 2018-06-13
 */
@RestController
@RequestMapping("/subscribes")
public class NideshopSubscribeController {
    @Autowired
    private INideshopSubscribeService nideshopSubscribeService;

    /**
     * 新增预约
     * @param nideshopSubscribe
     * @return
     */
    @PostMapping
    public ZyResult add(@RequestBody  NideshopSubscribe nideshopSubscribe){
        return ZyResult.ok(nideshopSubscribeService.create(nideshopSubscribe));
    }
    /**
     * 查询我的预约
     */
    @GetMapping
    public ZyResult subscribes(NideshopSubscribe nideshopSubscribe, Page page){
        //获取当前用户
        return ZyResult.ok(nideshopSubscribeService.selectPage(page,new EntityWrapper<>(nideshopSubscribe)));
    }
    /**
     * 修改预约
     * @param nideshopSubscribe
     * @return
     */
    @PutMapping
    public ZyResult cancel(@RequestBody  NideshopSubscribe nideshopSubscribe){
        return ZyResult.ok(nideshopSubscribeService.updateById(nideshopSubscribe));
    }
}

